home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
et
/
src
/
_as.s
next >
Wrap
Text File
|
1993-07-08
|
17KB
|
848 lines
.text
.align 4
.globl ___line
___line:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl %esp,%ebp
movl 20(%ebp),%ebx
movl (%ebx),%ecx /* pq_0 = pq_a[0] */
movl 8(%ebx),%eax /* pq_2 = pq_a[2] */
cmpl %ecx,%eax
jge 0f /* if (pq_2 >= pq_0) goto 0f */
movl %ecx,8(%ebx) /* pq_a[2] = pq_0 */
movl %eax,(%ebx) /* pq_a[0] = pq_2 */
movl 4(%ebx),%ecx /* pq_1 = pq_a[1] */
movl 12(%ebx),%eax /* pq_3 = pq_a[3] */
movl %ecx,12(%ebx) /* pq_a[3] = pq_1 */
movl %eax,4(%ebx) /* pq_a[1] = pq_3 */
0:
movl (%ebx),%ecx /* pq_0 = pq_a[0] */
andl $1,%ecx /* pq_0 &= 1 */
sall $2,%ecx /* pq_0 <<= 2 */
movl 24(%ebp),%esi
sall %cl,%esi /* %esi = col << pq_0 */
movl (%ebx),%ecx /* x = pq_a[0] */
sarl $1,%ecx /* x /= 2 */
movl 4(%ebx),%eax /* y = pq_a[1] */
movl $0x140,%edx
imull %edx /* y *= 80*sizeof(VRAM) */
addl %ecx,%eax /* x + y */
movl _G_nb+8,%ecx
testl %ecx,%ecx
je 0f /* if (!G_nb.page) goto 0f */
movl $0x20000,%ecx
0:
addl %ecx,%eax /* x+y+(!G_nb.page)?0:OFFSET */
movl %eax,%edi
movl $80,%ecx
sall $2,%ecx /* y_inc *= sizeof(VRAM) */
movl 12(%ebx),%eax /* pq_3 = pq_a[3] */
subl 4(%ebx),%eax /* dq = pq_3 - pq_a[1] */
cmpl $0,%eax
jge 0f /* if (dq >= 0) goto 0f */
negl %eax /* dq -= dq */
negl %ecx /* y_inc -= y_inc */
0:
movl 28(%ebp),%edx
movl %ecx,28(%ebp) /* 28(%ebp) = y_inc */
movl %eax,%ecx /* %ecx = dq */
movl 8(%ebx),%eax /* pq_2 = pq_a[2] */
subl (%ebx),%eax /* dp = pq_2 - pq_a[0] */
movl %eax,20(%ebp)
movw %ds,%ax
movw %ax,%fs
movw $0x120,%ax /* %ds = 0x120 */
movw %ax,%ds
movl %edx,%eax /* %eax = mm */
movl 20(%ebp),%edx /* %edx = dp */
movl %edi,%ebx /* %ebx = vram_p */
movl %ds:(%ebx),%edi /* %edi = *vram_p */
cmpl $0,%eax /* if (mm==P_SET) */
je P_SET /* goto P_SET */
cmpl $1,%eax /* if (mm==P_RES) */
je P_RES /* goto P_RES */
cmpl $2,%eax /* if (mm==P_NEG) */
je P_NEG /* goto P_NEG */
jmp 6f
.align 2
P_SET:
orl %esi,%edi /* set_bit(v, u) */
movl %ecx,%eax
orl %edx,%eax
je 6f /* if (!(dp|dq)) goto 6f */
cmpl $0,%ecx
jne 3f /* if (dq) goto 3f */
x_line:
movl %edx,%ecx
movl 24(%esp),%eax /* %eax = col */
movl $4,%edx /* %edx = sizeof(VRAM) */
cmpl $0,%ecx
jne 0f /* if (dp) goto 0f */
jmp 6f
.align 4
0:
shll $4,%esi /* u <<= 4 */
je 1f /* if (!u) goto 1f */
2:
orl %esi,%edi /* set_bit(v, u) */
loop 0b /* if (--dp) goto 0b */
jmp 6f
.align 4
1:
movl %edi,%ds:(%ebx)
addl %edx,%ebx /* vram_x_inc() */
movl %ds:(%ebx),%edi
movl %eax,%esi /* u = col */
jmp 2b
.align 4
3:
cmpl $0,%edx /* if (dp) goto 1f */
jne 1f
y_line:
movl 28(%esp),%edx /* %edx = y_inc */
cmpl $0,%ecx
jne 2f /* if (dq) goto 2f */
jmp 6f
.align 4
2:
movl %edi,%ds:(%ebx)
addl %edx,%ebx /* vram_y_inc() */
movl %ds:(%ebx),%edi
orl %esi,%edi /* set_bit(v, u) */
loop 2b /* if (dq) goto 2b */
jmp 6f
.align 4
1:
cmpl %edx,%ecx
jg 5f /* if (dq > dp) goto yx_line */
xy_line:
movl %ecx,%ebp /* %ebp = dq */
movl %edx,%ecx /* %ecx = dp */
movl %edx,%eax /* %eax = dp */
sarl $1,%eax /* slope = dp >> 1 */
cmpl $0,%ecx /* if (dp) goto 2f */
jne 2f
jmp 6f
.align 4
2:
addl %ebp,%eax /* slope += dq */
cmpl %edx,%eax
jl 3f /* if (slope < dp) goto 3f */
subl %edx,%eax /* slope -= dp */
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx /* vram_y_inc() */
movl %ds:(%ebx),%edi
3:
shll $4,%esi
je 3f
4:
orl %esi,%edi /* set_bit(v, u) */
loop 2b /* if (--dp) goto 2b */
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx /* vram_x_inc() */
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 4b
.align 4
5:
movl %ecx,%ebp /* %ebp = dq */
movl %ecx,%eax /* %eax = dq */
sarl $1,%eax /* slope = dq >> 1 */
cmpl $0,%ecx
jne 1f /* if (dq) goto 1f */
jmp 6f
.align 4
1:
addl %edx,%eax /* slope += dp */
cmpl %ebp,%eax
jl 2f /* if (slope < dq) goto 2f */
subl %ebp,%eax /* slope -= dq */
shll $4,%esi
je 3f
2:
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx /* vram_y_inc() */
movl %ds:(%ebx),%edi
orl %esi,%edi /* set_bit(v, u) */
loop 1b /* if (dq) goto 1b */
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx /* vram_x_inc() */
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 2b
.align 2
P_RES:
notl %esi
andl %esi,%edi
notl %esi
movl %ecx,%eax
orl %edx,%eax
je 6f
cmpl $0,%ecx
jne 3f
movl %edx,%ecx
movl 24(%esp),%eax
movl $4,%edx
cmpl $0,%ecx
jne 0f
jmp 6f
.align 4
0:
shll $4,%esi
je 1f
2:
notl %esi
andl %esi,%edi
notl %esi
loop 0b
jmp 6f
.align 4
1:
movl %edi,%ds:(%ebx)
addl %edx,%ebx
movl %ds:(%ebx),%edi
movl %eax,%esi
jmp 2b
.align 2
3:
cmpl $0,%edx
jne 1f
movl 28(%esp),%edx
cmpl $0,%ecx
jne 2f
jmp 6f
.align 4
2:
movl %edi,%ds:(%ebx)
addl %edx,%ebx
movl %ds:(%ebx),%edi
notl %esi
andl %esi,%edi
notl %esi
loop 2b
jmp 6f
.align 4
1:
cmpl %edx,%ecx
jg 5f
movl %ecx,%ebp
movl %edx,%ecx
movl %edx,%eax
sarl $1,%eax
cmpl $0,%ecx
jne 2f
jmp 6f
.align 4
2:
addl %ebp,%eax
cmpl %edx,%eax
jl 3f
subl %edx,%eax
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx
movl %ds:(%ebx),%edi
3:
shll $4,%esi
je 3f
4:
notl %esi
andl %esi,%edi
notl %esi
loop 2b
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 4b
.align 4
5:
movl %ecx,%ebp
movl %ecx,%eax
sarl $1,%eax
cmpl $0,%ecx
jne 1f
jmp 6f
.align 4
1:
addl %edx,%eax
cmpl %ebp,%eax
jl 2f
subl %ebp,%eax
shll $4,%esi
je 3f
2:
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx
movl %ds:(%ebx),%edi
notl %esi
andl %esi,%edi
notl %esi
loop 1b
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 2b
.align 4
P_NEG:
xorl %esi,%edi
movl %ecx,%eax
orl %edx,%eax
je 6f
cmpl $0,%ecx
jne 3f
movl %edx,%ecx
movl 24(%esp),%eax
movl $4,%edx
cmpl $0,%ecx
jne 0f
jmp 6f
.align 4
0:
shll $4,%esi
je 1f
2:
xorl %esi,%edi
loop 0b
jmp 6f
.align 4
1:
movl %edi,%ds:(%ebx)
addl %edx,%ebx
movl %ds:(%ebx),%edi
movl %eax,%esi
jmp 2b
.align 4
3:
cmpl $0,%edx
jne 1f
movl 28(%esp),%edx
cmpl $0,%ecx
jne 2f
jmp 6f
.align 4
2:
movl %edi,%ds:(%ebx)
addl %edx,%ebx
movl %ds:(%ebx),%edi
xorl %esi,%edi
loop 2b
jmp 6f
.align 4
1:
cmpl %edx,%ecx
jg 5f
movl %ecx,%ebp
movl %edx,%ecx
movl %edx,%eax
sarl $1,%eax
cmpl $0,%ecx
jne 2f
jmp 6f
.align 4
2:
addl %ebp,%eax
cmpl %edx,%eax
jl 3f
subl %edx,%eax
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx
movl %ds:(%ebx),%edi
3:
shll $4,%esi
je 3f
4:
xorl %esi,%edi
loop 2b
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 4b
.align 4
5:
movl %ecx,%ebp
movl %ecx,%eax
sarl $1,%eax
cmpl $0,%ecx
jne 1f
jmp 6f
.align 4
1:
addl %edx,%eax
cmpl %ebp,%eax
jl 2f
subl %ebp,%eax
shll $4,%esi
je 3f
2:
movl %edi,%ds:(%ebx)
addl 28(%esp),%ebx
movl %ds:(%ebx),%edi
xorl %esi,%edi
loop 1b
jmp 6f
.align 4
3:
movl %edi,%ds:(%ebx)
addl $4,%ebx
movl %ds:(%ebx),%edi
movl 24(%esp),%esi
jmp 2b
.align 4
6:
movl %edi,%ds:(%ebx)
movw %fs,%ax
movw %ax,%ds
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.align 4
.globl ___x_rot
___x_rot:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
pushl %edi
pushl %esi
pushl %ebx
movl _G_et,%ebx /* et_p = G_et */
movl _G_nb,%eax
movl %eax,-12(%ebp) /* i = G_nb.edge */
testl %eax,%eax /* if (!i) goto 2f */
je 2f
1:
movl 8(%ebx),%eax /* et_p->y1 */
imull 12(%ebp) /* *= l_3 */
movl %eax,%esi /* low */
movl %edx,%edi /* high */
movl 16(%ebx),%eax /* et_p->z1 */
imull 8(%ebp) /* *= l_2 */
subl %esi,%eax /* subl low */
sbbl %edi,%edx /* subl high+CF */
testl %eax,%eax /* if ( >= 0 ) goto 0f */
jge 0f
addl $65535,%eax /* 負の少数点以下の丸め */
0:
shrd $16,%edx,%eax /* /= GETA_ET */
movl %eax,%ecx
movl 16(%ebx),%eax /* et_p->z1 */
movl %ecx,16(%ebx) /* et_p->z1 <== */
imull 12(%ebp) /* *= l_3 */
movl %eax,%esi
movl %edx,%edi
movl 8(%ebx),%eax /* et_p->y1 */
imull 8(%ebp) /* *= l_2 */
addl %esi,%eax /* addl low */
adcl %edi,%edx /* addl high+CF */
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,8(%ebx) /* et_p->y1 <== */
movl 12(%ebx),%eax /* et_p->y2 */
imull 12(%ebp) /* *= l_3 */
movl %eax,%esi
movl %edx,%edi
movl 20(%ebx),%eax /* et_p->z2 */
imull 8(%ebp) /* *= l_2 */
subl %esi,%eax
sbbl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,%ecx
movl 20(%ebx),%eax /* et_p->z2 */
movl %ecx,20(%ebx) /* et_p->z2 <== */
imull 12(%ebp) /* *= l_3 */
movl %eax,%esi
movl %edx,%edi
movl 12(%ebx),%eax /* et_p->y2 */
imull 8(%ebp) /* *= l_2 */
addl %esi,%eax
adcl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,12(%ebx) /* et_p->y2 <== */
addl $24,%ebx /* et_p++ */
decl -12(%ebp) /* i-- */
jne 1b /* if (i) goto 1b */
2:
movl _G_f,%eax /* if (!test_bit(G_f, f_REV)) goto 0f */
andl $0x1000000,%eax
je 0f
pushl 12(%ebp)
pushl 8(%ebp)
pushl $_G_ps+8
pushl $_G_ps+4
movl _G_pm+8,%eax
subl _G_pm+4,%eax
pushl %eax
pushl $0
call _revolution
0:
leal -28(%ebp),%esp
popl %ebx
popl %esi
popl %edi
leave
ret
.align 4
.globl ___y_rot
___y_rot:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
pushl %edi
pushl %esi
pushl %ebx
movl _G_et,%ebx
movl _G_nb,%eax
movl %eax,-12(%ebp)
testl %eax,%eax
je 2f
1:
movl 16(%ebx),%eax
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl (%ebx),%eax
imull 8(%ebp)
subl %esi,%eax
sbbl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,%ecx
movl (%ebx),%eax
movl %ecx,(%ebx)
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 16(%ebx),%eax
imull 8(%ebp)
addl %esi,%eax
adcl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,16(%ebx)
movl 20(%ebx),%eax
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 4(%ebx),%eax
imull 8(%ebp)
subl %esi,%eax
sbbl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,%ecx
movl 4(%ebx),%eax
movl %ecx,4(%ebx)
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 20(%ebx),%eax
imull 8(%ebp)
addl %esi,%eax
adcl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,20(%ebx)
addl $24,%ebx
decl -12(%ebp)
jne 1b
2:
movl _G_f,%eax
andl $0x1000000,%eax
je 0f
pushl 12(%ebp)
pushl 8(%ebp)
pushl $_G_ps
pushl $_G_ps+8
pushl $0
movl _G_pm+8,%eax
subl _G_pm+4,%eax
pushl %eax
call _revolution
0:
leal -28(%ebp),%esp
popl %ebx
popl %esi
popl %edi
leave
ret
.align 4
.globl ___z_rot
___z_rot:
pushl %ebp
movl %esp,%ebp
subl $16,%esp
pushl %edi
pushl %esi
pushl %ebx
movl _G_et,%ebx
movl _G_nb,%eax
movl %eax,-12(%ebp)
testl %eax,%eax
je 2f
1:
movl 8(%ebx),%eax
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl (%ebx),%eax
imull 8(%ebp)
subl %esi,%eax
sbbl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,%ecx
movl (%ebx),%eax
movl %ecx,(%ebx)
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 8(%ebx),%eax
imull 8(%ebp)
addl %esi,%eax
adcl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,8(%ebx)
movl 12(%ebx),%eax
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 4(%ebx),%eax
imull 8(%ebp)
subl %esi,%eax
sbbl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,%ecx
movl 4(%ebx),%eax
movl %ecx,4(%ebx)
imull 12(%ebp)
movl %eax,%esi
movl %edx,%edi
movl 12(%ebx),%eax
imull 8(%ebp)
addl %esi,%eax
adcl %edi,%edx
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
shrd $16,%edx,%eax
movl %eax,12(%ebx)
addl $24,%ebx
decl -12(%ebp)
jne 1b
2:
movl _G_f,%eax
andl $0x1000000,%eax
je 0f
pushl 12(%ebp)
pushl 8(%ebp)
pushl $_G_ps
pushl $_G_ps+4
pushl $0
pushl $0
call _revolution
0:
leal -28(%ebp),%esp
popl %ebx
popl %esi
popl %edi
leave
ret
.align 4
.globl ___cul_r
___cul_r:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl %esp,%ebp
movl $_G_mv,%ebx
xorl %esi,%esi /* i = 0 */
0:
movl 8(%ebx,%esi),%eax /* G_mv[i].z */
movl 24(%ebp),%edi
sall $4,%edi
movl 8(%ebx,%edi),%edx /* G_mv[min_i].z */
subl %edx,%eax /* G_mv[i].z - G_mv[min_i].z */
imull 28(%ebp) /* *= r_d */
idivl 32(%ebp) /* /= z_d */
movl 24(%ebp),%edi
sall $4,%edi
movswl 14(%ebx,%edi),%edx
addl %edx,%eax /* += G_mv[min_i].r */
movw %ax,14(%ebx,%esi) /* G_mv[i].r <== */
movl %esi,%eax /* &G_mv[i] */
addl $16,%esi /* += sizeof(MOVE) */
cmpw $255,12(%ebx,%eax)/* if (G_mv[i].key == EOK) break; */
jne 0b
1:
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.align 4
.globl ___clip_z1
___clip_z1:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl %esp,%ebp
movl 20(%ebp),%ebx /* &a[0] */
movl 24(%ebp),%eax /* z_view */
subl 16(%ebx),%eax /* z_view-a[4] */
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
sarl $16,%eax /* /= GETA_ET */
movl 4(%ebx),%edx
subl (%ebx),%edx
imull %edx /* *= (a[1]-a[0]) */
movl 20(%ebx),%ecx
subl 16(%ebx),%ecx
idivl %ecx /* /= (a[5]-a[4]) */
sall $16,%eax /* *= GETA_ET */
addl (%ebx),%eax /* += a[0] */
movl %eax,(%ebx) /* a[0] <== */
movl 24(%ebp),%eax
subl 16(%ebx),%eax
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
sarl $16,%eax
movl 12(%ebx),%edx
subl 8(%ebx),%edx
imull %edx
movl 20(%ebx),%ecx
subl 16(%ebx),%ecx
idivl %ecx
sall $16,%eax
addl 8(%ebx),%eax
movl %eax,8(%ebx)
movl 24(%ebp),%eax
movl %eax,16(%ebx)
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.align 4
.globl ___clip_z2
___clip_z2:
pushl %ebp
pushl %edi
pushl %esi
pushl %ebx
movl %esp,%ebp
movl 20(%ebp),%ebx
movl 24(%ebp),%eax
subl 20(%ebx),%eax
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
sarl $16,%eax
movl (%ebx),%edx
subl 4(%ebx),%edx
imull %edx
movl 16(%ebx),%ecx
subl 20(%ebx),%ecx
idivl %ecx
sall $16,%eax
addl 4(%ebx),%eax
movl %eax,4(%ebx)
movl 24(%ebp),%eax
subl 20(%ebx),%eax
testl %eax,%eax
jge 0f
addl $65535,%eax
0:
sarl $16,%eax
movl 8(%ebx),%edx
subl 12(%ebx),%edx
imull %edx
movl 16(%ebx),%ecx
subl 20(%ebx),%ecx
idivl %ecx
sall $16,%eax
addl 12(%ebx),%eax
movl %eax,12(%ebx)
movl 24(%ebp),%eax
movl %eax,20(%ebx)
popl %ebx
popl %esi
popl %edi
popl %ebp
ret